package com.smedi.ismedi.constructionproject.core.port.adapter.persistence.mybatis.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.smedi.ismedi.constructionproject.core.application.query.vo.ProjectBasicVo;
import com.smedi.ismedi.constructionproject.core.port.adapter.persistence.model.ProjectBasicEntity;
import com.smedi.ismedi.database.starter.annotation.SqlItem;
import com.smedi.ismedi.database.starter.annotation.SqlPermission;
import com.smedi.ismedi.database.starter.interceptor.permission.SqlItemEnum;
import org.apache.ibatis.annotations.Param;

import java.util.List;

/**
 * @Author: xulinjun
 * @Date: 2021-6-8 10:52
 */
public interface ProjectBasicMapper extends BaseMapper<ProjectBasicEntity> {
    @SqlPermission({
            @SqlItem(item = SqlItemEnum.project, table = {ProjectBasicEntity.class}, sqlField = "id")
    })
    IPage<ProjectBasicVo> selectProjectBasicVoIncludeChildrenPagination(@Param("page") Page<ProjectBasicVo> page,
                                                                        @Param("projectName") String projectName,
                                                                        @Param("projectCode") String projectCode,
                                                                        @Param("projectManager") String projectManager,
                                                                        @Param("segHrOrganizationIds") List<List<Long>> segHrOrganizationIds);

    @SqlPermission({
            @SqlItem(item = SqlItemEnum.project, table = {ProjectBasicEntity.class}, sqlField = "id")
    })
    IPage<ProjectBasicVo> selectProjectBasicVoPagination(@Param("page") Page<ProjectBasicVo> page,
                                                         @Param("projectName") String projectName,
                                                         @Param("projectCode") String projectCode,
                                                         @Param("projectManager") String projectManager,
                                                         @Param("hrOrganizationId") Long hrOrganizationId);

    @SqlPermission({
            @SqlItem(item = SqlItemEnum.project, table = {ProjectBasicEntity.class}, sqlField = "id")
    })
    IPage<ProjectBasicVo> selectProjectManagementInfoPagination(@Param("page") Page<ProjectBasicVo> page,
                                                                @Param("projectName") String projectName,
                                                                @Param("projectCode") String projectCode,
                                                                @Param("projectManager") String projectManager,
                                                                @Param("hrOrganizationId") Long hrOrganizationId,
                                                                @Param("supervisionUnit") String supervisionUnit,
                                                                @Param("projectStatus") String projectStatus,
                                                                @Param("projectCategory") String projectCategory,
                                                                @Param("contractDurationBegin") String contractDurationBegin,
                                                                @Param("contractDurationEnd") String contractDurationEnd,
                                                                @Param("epcType") String epcType,
                                                                @Param("projectIds") List<Long> projectIds);

    @SqlPermission({
            @SqlItem(item = SqlItemEnum.project, table = {ProjectBasicEntity.class}, sqlField = "id")
    })
    IPage<ProjectBasicVo> selectProjectManagementInfoPaginationInIds(@Param("page") Page<ProjectBasicVo> page,
                                                                @Param("projectName") String projectName,
                                                                @Param("projectCode") String projectCode,
                                                                @Param("projectManager") String projectManager,
                                                                @Param("hrOrganizationId") Long hrOrganizationId,
                                                                @Param("supervisionUnit") String supervisionUnit,
                                                                @Param("projectStatus") String projectStatus,
                                                                @Param("projectCategory") String projectCategory,
                                                                @Param("contractDurationBegin") String contractDurationBegin,
                                                                @Param("contractDurationEnd") String contractDurationEnd,
                                                                @Param("ids") List<Long> ids);

    long updateDingDeptKeyByProjectName(@Param("projectName") String projectName,@Param("dingDeptKey") String dingDeptKey);
}
